import { defineStore } from "pinia";

const view = {
    setting: false,
    map: false,
}

type DefaultStoreKeys = keyof typeof view;
type IIndex = {
    [K in DefaultStoreKeys]: number;
}

const zIndex: IIndex = {
    setting: 1,
    map: 1
}

const defaultStore = {
    view,
    zIndex,
    curIndex: 10
};

export const usePop = defineStore("pop", {
    state: () => defaultStore,

    getters: {},
    actions: {
        show(val: DefaultStoreKeys) {
            this.view[val] = true;
            this.curIndex++;
            this.zIndex[val] = this.curIndex;
        },
        hide(val: DefaultStoreKeys) {
            this.view[val] = false;
        },
    }
});
